#include "application.h"


namespace androidplus{
void activityOnStart(ANativeActivity* activity) {
	androidplus::application::cur_app()->cur_activity()->on_start();
}

void activityOnResume(ANativeActivity* activity) {
	androidplus::application::cur_app()->cur_activity()->on_resume();
}


void* activityOnSaveInstanceState(ANativeActivity* activity, size_t* outSize) {
	return androidplus::application::cur_app()->cur_activity()->on_save_instance_state(outSize);


}


void activityOnPause(ANativeActivity* activity) {
	androidplus::application::cur_app()->cur_activity()->on_pause();
}

void activityOnStop(ANativeActivity* activity) {
	androidplus::application::cur_app()->cur_activity()->on_stop();
}

void activityOnDestroy(ANativeActivity* activity) {
	androidplus::application::cur_app()->cur_activity()->on_destroy();
    delete application::cur_app()->cur_activity();
}

void activityOnWindowFocusChanged(ANativeActivity* activity, int hasFocus) {
	androidplus::application::cur_app()->cur_activity()->on_window_focus_changed(hasFocus);
}

void activityOnNativeWindowCreated(ANativeActivity* activity,ANativeWindow* window)
{
	androidplus::application::cur_app()->cur_activity()->on_native_window_created(window);
}

void activityOnNativeWindowResized(ANativeActivity* activity,ANativeWindow* window) {
	androidplus::application::cur_app()->cur_activity()->on_native_window_resized(window);

}

void activityOnNativeWindowRedrawNeeded(ANativeActivity* activity,ANativeWindow* window) {
	androidplus::application::cur_app()->cur_activity()->on_native_window_redraw_needed(window);

}

void activityOnNativeWindowDestroyed(ANativeActivity* activity,ANativeWindow* window) {
	androidplus::application::cur_app()->cur_activity()->on_native_window_destroyed(window);

}

void activityOnInputQueueCreated(ANativeActivity* activity, AInputQueue* queue) {

	androidplus::application::cur_app()->cur_activity()->on_input_queue_created(queue);
}

void activityOnInputQueueDestroyed(ANativeActivity* activity,AInputQueue* queue) {
	androidplus::application::cur_app()->cur_activity()->on_input_queue_destroyed(queue);

}

void activityOnContentRectChanged(ANativeActivity* activity, const ARect* rect) {
	androidplus::application::cur_app()->cur_activity()->on_content_rect_changed(rect);

}

void activityOnConfigurationChanged(ANativeActivity* activity) {
	androidplus::application::cur_app()->cur_activity()->on_configuration_changed();

}
void activityOnLowMemory(ANativeActivity* activity) {

	androidplus::application::cur_app()->cur_activity()->on_low_memory();

}
}


extern "C" void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState,size_t savedStateSize) {


	//LOGI("callbacks called1");

	    activity->callbacks->onConfigurationChanged =
				androidplus::activityOnConfigurationChanged;
		activity->callbacks->onContentRectChanged =androidplus::activityOnContentRectChanged;
		activity->callbacks->onDestroy =androidplus::activityOnDestroy;
		activity->callbacks->onInputQueueCreated = androidplus::activityOnInputQueueCreated;
		activity->callbacks->onInputQueueDestroyed = androidplus::activityOnInputQueueDestroyed;
		//LOGI("callbacks called2");
		activity->callbacks->onLowMemory = androidplus::activityOnLowMemory;
		activity->callbacks->onNativeWindowCreated = androidplus::activityOnNativeWindowCreated;
		activity->callbacks->onNativeWindowDestroyed =
				androidplus::activityOnNativeWindowDestroyed;
		activity->callbacks->onNativeWindowRedrawNeeded =
				androidplus::activityOnNativeWindowRedrawNeeded;
		activity->callbacks->onNativeWindowResized = androidplus::activityOnNativeWindowResized;
		activity->callbacks->onPause = androidplus::activityOnPause;
		activity->callbacks->onResume = androidplus::activityOnResume;
		activity->callbacks->onSaveInstanceState = androidplus::activityOnSaveInstanceState;
		activity->callbacks->onStart = androidplus::activityOnStart;
		activity->callbacks->onStop = androidplus::activityOnStop;
		activity->callbacks->onWindowFocusChanged = androidplus::activityOnWindowFocusChanged;

		androidplus::application::cur_app()->cur_activity()->init(activity,savedState,savedStateSize);

}


